package cn.usian.controller;

import cn.usian.pojo.Student;
import cn.usian.service.StudentService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
import org.springframework.web.bind.annotation.*;


@CrossOrigin(allowedHeaders = "*")
@RestController
@RequestMapping("student")
public class StudentController {
    @Autowired
    private StudentService studentService;

    @RequestMapping("findPage")
    public Page<Student> findPage(@RequestParam(defaultValue = "1") Integer pageIndex, String name){
        return studentService.findPage(pageIndex,name);
    }

    @RequestMapping("add")
    public void add(@RequestBody Student student){
        System.out.println(student);
        studentService.add(student);
    }
    @RequestMapping("del")
    public void del(Long id){
        studentService.del(id);
    }
}
